﻿@model IEnumerable<vnMcdonald.Models.Category>

@{
    ViewBag.Title = "Categories";
    Layout = "~/Views/Shared/_LayoutAdmin.cshtml";
}
<script src="~/Content/admin/js/script.js"></script>
<h2>DANH MỤC SẢN PHẨM</h2>
@using (Html.BeginForm("CategoriesCreate", "admin", FormMethod.Post, new { @encType = "multipart/form-data" }))
{ 
    <p>@Html.TextBox("txtaddcategory",null, new {@placeholder = "Nhập tên danh mục" })
    <input type="submit" value="Thêm" id="btnaddcategory" />
    </p>
}
<table class="thetable">
        <tr>
            <th scope="col">STT</th>
            <th scope="col">Tên danh mục</th>
            <th scope="col">Sắp xếp</th>
            <th scope="col">Trạng thái</th>
            <th scope="col">Tùy chọn</th>
        </tr>
    <tbody>
@{
    int i = 0;
}
@foreach (var item in Model)
{
    i = i + 1;
        <tr>
            <td>@i</td>
            <td class="text-center">
                @Html.DisplayFor(modelItem => item.Name)
                @Html.HiddenFor(modelItem => item.Name, new {id = item.CategoryId })
            </td>
            <td class="text-center">
                @Html.DisplayFor(modelItem => item.Order)
            </td>
            <td class="text-center" id="row-@item.CategoryId">
                @if ((int)item.IsActive == 1)
                {
                    @Ajax.ActionLink("Mở", "Update_Status_Categories", new { id = item.CategoryId }, new AjaxOptions { InsertionMode = InsertionMode.Replace, UpdateTargetId = "row-" + string.Format("{0}", item.CategoryId) }, new {@class ="enable" })
                }
                else {
                    @Ajax.ActionLink("Đóng", "Update_Status_Categories", new { id = item.CategoryId }, new AjaxOptions { InsertionMode = InsertionMode.Replace, UpdateTargetId = "row-" + string.Format("{0}", item.CategoryId) }, new {@class ="disable" })
                }
                
            </td>
            <td class="text-center">
                <a href="@Url.Action("CategoriesEdit","admin",new { id=item.CategoryId })" title="Sửa" class="edit"><span>Sửa</span></a>
                <a href="@Url.Action("CategoriesDel","admin",new { id=item.CategoryId })" title="Xóa" class="delete"><span>Xóa</span></a>
            </td>
        </tr>
}
    </tbody>

</table>
